package com.ruoyi.community.service.impl;

import java.util.Iterator;
import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.community.mapper.BaseNoticeSectionMapper;
import com.ruoyi.community.domain.BaseNoticeSection;
import com.ruoyi.community.service.IBaseNoticeSectionService;

/**
 * 公告板块Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-12-16
 */
@Service
public class BaseNoticeSectionServiceImpl implements IBaseNoticeSectionService 
{
    @Autowired
    private BaseNoticeSectionMapper baseNoticeSectionMapper;

    /**
     * 查询公告板块
     * 
     * @param sectionId 公告板块ID
     * @return 公告板块
     */
    @Override
    public BaseNoticeSection selectBaseNoticeSectionById(String sectionId)
    {
        return baseNoticeSectionMapper.selectBaseNoticeSectionById(sectionId);
    }

    /**
     * 查询管理员可编辑的公告板块（除去社区党建与业委会公告）
     *
     * @param baseNoticeSection 公告板块
     * @return 公告板块集合
     */
    @Override
    public List<BaseNoticeSection> selectBaseNoticeSectionList(BaseNoticeSection baseNoticeSection)
    {
        baseNoticeSection.setCommunityId(Long.valueOf(SecurityUtils.getCommunityId()));
        baseNoticeSection.setStatus("1");
        return baseNoticeSectionMapper.selectBaseNoticeSectionList(baseNoticeSection);
    }

    /**
     * 查询所有公告板块
     *
     * @param baseNoticeSection 公告板块
     * @return 公告板块集合
     */
    @Override
    public List<BaseNoticeSection> selectAllBaseNoticeSectionList(BaseNoticeSection baseNoticeSection)
    {
        baseNoticeSection.setCommunityId(Long.valueOf(SecurityUtils.getCommunityId()));
        return baseNoticeSectionMapper.selectBaseNoticeSectionList(baseNoticeSection);
    }

    /**
     * 新增公告板块
     * 
     * @param baseNoticeSection 公告板块
     * @return 结果
     */
    @Override
    public int insertBaseNoticeSection(BaseNoticeSection baseNoticeSection)
    {
        baseNoticeSection.setCreater(SecurityUtils.getUsername());
        baseNoticeSection.setCommunityId(Long.valueOf(SecurityUtils.getCommunityId()));
        baseNoticeSection.setStatus("1");
        return baseNoticeSectionMapper.insertBaseNoticeSection(baseNoticeSection);
    }

    /**
     * 批量删除公告板块
     *
     * @param sectionIds 需要删除的公告板块ID
     * @return 结果
     */
    @Override
    public int deleteBaseNoticeSectionByIds(String[] sectionIds)
    {
        return baseNoticeSectionMapper.deleteBaseNoticeSectionByIds(sectionIds);
    }
}
